import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:mahjong/const/MahjongSystemConst.dart';
import 'package:mahjong/util/ProviderClean.dart';
import 'package:mahjong/entity/UserEntityInfo.dart';
import 'package:mahjong/page/mahjong/MahjongGameIndex.dart';
import 'package:mahjong/util/CustomRoute.dart';
import 'package:mahjong/util/DictionaryConst.dart';
import 'package:provider/provider.dart';

class InsertHome {
  static void addHome(BuildContext context, String roomType, String roomCode) {
    ProviderClean.cleanAll();
    var loginUser = Provider.of<UserEntityInfo>(context, listen: false);
    List mahjongHome = ["WZ_MAHJONG", ""];
    String url = DictionaryConst.wsUrl +
        "?Authory=" +
        loginUser.tokenAuthority +
        "&roomCode=" +
        roomCode;
    if (mahjongHome.contains(roomType)) {
      Navigator.of(context).pushAndRemoveUntil(
          CustomRoute(MahjongGameIndex(url), AnimationEnum.zoom),
          (route) => route == null);
    }
  }
}
